﻿using Sgr.Domain.Entities;

namespace Sgr.UPMS.Application.Services
{
    public interface IOrgBasicDataCacheService
    {
        /// <summary>
        /// 获取组织名称
        /// </summary>
        /// <param name="orgId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<OrgBasicDataCacheModel> GetOrgNameAsync(long orgId, CancellationToken cancellationToken = default);

        /// <summary>
        /// 获取部门信息
        /// </summary>
        /// <param name="orgId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<IReadOnlyDictionary<long, OrgBasicDataCacheModel>> GetDepartmentNamesAsync(long orgId, CancellationToken cancellationToken = default);

        /// <summary>
        /// 获取岗位信息
        /// </summary>
        /// <param name="orgId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<IReadOnlyDictionary<long, OrgBasicDataCacheModel>> GetDutyNamesAsync(long orgId, CancellationToken cancellationToken = default);

        /// <summary>
        /// 清除组织相关所有缓存
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        Task RemoveOrgAllCacheAsync(long orgId);

        /// <summary>
        /// 清除组织缓存
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        Task RemoveOrgCacheAsync(long orgId);

        /// <summary>
        /// 清除部门缓存
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        Task RemoveDepartmentCacheAsync(long orgId);

        /// <summary>
        /// 清除岗位缓存
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        Task RemoveDutyCacheAsync(long orgId);
    }

    public class OrgBasicDataCacheModel
    {
        public OrgBasicDataCacheModel(string name, string value)
        {
            Name = name;
            Value = value;
        }

        public string Name { get; set; }
        public string Value { get; set; }
        public string ParentValue { get; set; } = string.Empty;
        public EntityStates States { get; set; }
    }
}